<?php
$action=htmlentities($_GET[act], ENT_QUOTES);
if(empty($action)){
?>
<form name='mysql' id='mysql' method='post' action='?act=scan'>
Masukkan IP <font color='red'>ex: 192.168.1.1</font> <input name='ip' id='ip' type='text'>&nbsp;<input name='submit' type='submit' value='Scan'>
</form>
<?
}
elseif($action=='scan'){
$ip=$_POST[ip];

function check_port($ip,$port) {
$conn = @fsockopen($ip, $port, $errno, $errstr, 0.2);
if ($conn) {
fclose($conn);
return true;
}
}

function server_report($ip) {
$report = array();
$svcs = array('21'=>'FTP',
'22'=>'SSH',
'25'=>'SMTP',
'80'=>'HTTP',
'110'=>'POP3',
'143'=>'IMAP',
'3306'=>'MySQL');
foreach ($svcs as $port=>$service) {
$report[$service] = check_port($ip,3306);
}
return $report;
}

$report = server_report($ip);
?>
<table>
<tr>
<td>Service</td>
<td>Status <?php echo"ip= $ip;" ?></td>
</tr>
<tr>
<td>MySQL</td>
<td><?php echo $report['MySQL'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
</table>
<?

}else{
header ('location:singlemysql.php');
}
?>
